using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection.Emit;
using System.Text;
using System.Threading.Tasks;
using bitzhuwei.Compiler;
using static System.Formats.Asn1.AsnWriter;

namespace bitzhuwei.AnsiCFormat {
    /// <summary>
    /// Correspond to the Vn node declaration in the grammar(AnsiC).
    /// </summary>
    internal partial class Vndeclaration : Vnexternal_declaration {
        private readonly Vndeclaration_specifiers r2;
        private readonly Vninit_declarator_list? r1;
        private readonly Token r0;

        // [074]=declaration : declaration_specifiers ';' ;
        // [075]=declaration : declaration_specifiers init_declarator_list ';' ;

        // [75]=declaration : declaration_specifiers init_declarator_list ';' ;
        // dumped by DefaultExtractor
        internal Vndeclaration(Vndeclaration_specifiers r2, Vninit_declarator_list? r1, Token r0) {
            this.r2 = r2;
            this.r1 = r1;
            this.r0 = r0;
            this._scope = new TokenRange(r2, r0);
        }

        private readonly TokenRange _scope;
        public override TokenRange Scope => _scope;

        public override void Format(TextWriter writer, FormatContext context) {
            throw new NotImplementedException();
        }

        public override void FullFormat(BlankConfig preConfig, TextWriter writer, FormatContext context) {
            context.PrintBlanksAnd(r2, preConfig, writer);
            var config = new BlankConfig();
            if (r1 != null) {
                context.PrintCommentsBetween(r2, r1, config, writer);
                context.PrintBlanksAnd(r1, config, writer);
                context.PrintCommentsBetween(r1, r0, config, writer);
            }
            else {
                context.PrintCommentsBetween(r2, r0, config, writer);
            }
            context.PrintBlanksAnd(r0, config, writer);
        }

        public override IEnumerable<string> YieldTokens(TextWriter writer, FormatContext context) {
            throw new NotImplementedException();
        }
    }
}
